#include <iostream>
using namespace std;
int t;
string s;
bool green(){
	int i = 0, j = s.size() - 1;
	while(i < j && s[i] == s[j]){
		i++;
		j--;
	}
	if (i < j)  return false;
	else return true;
}
int main(){
	cin >> t;
	while(t--){
		cin >> s;
		if (green()) cout << 1 << endl;
		
		else cout << 2 << endl;
	}

    return 0;
}


